
function ave_recons = matrix2signal(L,N,NSample,windowlen,step)
    
    N = (NSample-1)*step+windowlen;
    Weight = zeros(1,N);
    Recs = zeros(1,N);

    for i = 1 : NSample
        Start  = 1+(i-1)*step;
        patch_recons  = L(i,:);
        Recs(Start : Start+windowlen-1) = Recs(Start : Start+windowlen-1) + patch_recons;
        Weight(Start : Start+windowlen-1) = Weight(Start : Start+windowlen-1) + 1;
    end
    ave_recons = Recs./Weight;
    
end